<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/view/system/common/head.jsp"%>
<style>
 .labelTd{
    width:100px;
    text-align:right;
 }
</style>
<body>
	<form id="parameterUpdateForm" name="parameterUpdateForm" method="post">
		<div id="p" class="easyui-panel" title="添加参数" style="padding: 10px; background: #fafafa;text-align:center;">
			<fieldset>
				<legend style="color: blue;font-size:1.5" > 参数信息 </legend>
				<input type="hidden" name="id" value="${parameter.id }">
				<table class="infoTable">
					<tr>
						<td class="labelTd">参数类型 :</td>
						<td class="redText"><!-- <s:select disabled="true" id="updateParameter_type" value="#request.parameter.type" name="updateParameter.type" list="#request.parameterTypeList"
								listKey="value" listValue="name" style="width:150px" /> -->
						<select id="updateParameter_type" name="type"  style="width: 100px; border-radius: 5px;height: 24px;"
						onchange="parameterTypeChanged()"  value="${parameter.type }" >
						
						   <c:forEach items="${parameterTypeList}" var="parameterTypeItem" >
						       <c:if test="${parameterTypeItem.value == parameter.type}">
						         <option value="${parameterTypeItem.value }" selected="selected">${parameterTypeItem.name }</option>
						       </c:if>
						         <c:if test="${parameterTypeItem.value != parameter.type}">
						         <option value="${parameterTypeItem.value }">${parameterTypeItem.name }</option>
						       </c:if>
						  </c:forEach>
						 </select>

						</td>
					</tr>
					<tr>
						<td class="labelTd">名称 <span class="colrRed"> * </span>：</td>
						<td ><input type="text" id="updateParameter_name" value="${parameter.name }" name="name" maxlength="30" class="easyui-validatebox myinput" 
							required="true" validType="length[1,30]" 
							missingMessage="请输入名称"  placeholder="请输入名称"/></td>
						<td  class="labelTd" >编码<span class="colrRed"> * </span>：</td>
						<td ><input type="text" id="updateParameter_code" value="${parameter.code }" name="code" class="easyui-validatebox myinput" disabled="true" /></td>
					</tr>
					<tr id="singerParameterTR">
						<td class="labelTd">参数值：</td>
						<td ><input type="text" id="updateParameter_value" value="${parameter.value }" name="value"  maxlength="30" class="easyui-validatebox myinput" 
							  placeholder="请输入参数值"/></td>
						<td class="labelTd">更改后生效时间 :</td>
						<td >
					<!-- 	<s:select id="updateParameter_effectType" name="updateParameter.effectType" list="#request.parameterEffectTypeList" listKey="value" listValue="name" style="width:150px" /> -->
						<select id="newParameter_effectType" name="effectType"  class="easyui-combobox"
                           style="width: 100px; border-radius: 5px;height: 24px;">
						  <c:forEach items="${parameterEffectTypeList}" var="parameterEffectTypeItem" >
						      <c:if test="${parameterTypeItem.value == parameter.effectType}">
						         <option value="${parameterEffectTypeItem.value }" selected="selected" >${parameterEffectTypeItem.name }</option>
						       </c:if>
						      <c:if test="${parameterTypeItem.value != parameter.effectType}">
						           <option value="${parameterEffectTypeItem.value }">${parameterEffectTypeItem.name }</option>
						       </c:if>
						   
						  </c:forEach>
						 </select>
						</td>
					</tr>
				</table>
			</fieldset>
			<div  style="text-align:center;">
				<br /> <a class="easyui-linkbutton myLink" iconCls="icon-ok" 
				onclick="submitForm()">更新</a> 
				&nbsp;&nbsp;&nbsp; <a  class="easyui-linkbutton myLink" iconCls="icon-undo"
					onclick="resetFrom()">重置 </a>
			</div>
		</div>
	</form>
	</body>
	<script>
	$(document).ready(function() {
		parameterTypeChanged();
	});

	//重置
	function resetFrom() {
		$("#parameterUpdateForm").form("reset");
	}

	//页面提交
	function submitForm() {
		//判断参数是否为空
		var valid = $('#parameterUpdateForm').form('validate');
		if (valid) {
			//获取页面上所有的参数
			//var param = getFormElementsForUrl();
			//提交后台处理  
			//$.post("doParameterUpdate.action" + param, callbackUpdate);
			var param = $("#parameterUpdateForm").serializeJson(true);
			$.axs("parameter/doParameterUpdate.action", param,
		            function(data){
				if(data.status == 1){
					$.messager.alert("提示信息",data.msg, 'info', function() {
						parent.$("#parameterDataGrid").datagrid('reload');		
					});
				}else{
					$.messager.alert("提示信息", data.msg, 'error');
				}
			});	
			
		}
	}

	
	function parameterTypeChanged() {
		var parameterType = $('#updateParameter_type option:selected') .val();
		console.log(parameterType);
		if (parameterType == 1) {
			//单参数，显示
			$('#singerParameterTR').show();
		} else if (parameterType == 2) {
			//多参数
			$('#singerParameterTR').hide();
		}
	}
</script>
</html>